package com.gxm.模式.代理.动态.jdk;

import java.lang.reflect.Proxy;

public class Demo {
    public static void main(String[] args) {
        IUserDao userDao = new UserDaoImpl();
        InvocationHandImpl invocationHand = new InvocationHandImpl(userDao);
        ClassLoader classLoader = userDao.getClass().getClassLoader();
        Class<?>[] interfaces = userDao.getClass().getInterfaces();
        //调用动态代理实例
        IUserDao iUserDao = (IUserDao) Proxy.newProxyInstance(classLoader,interfaces,invocationHand);
        iUserDao.add();
        iUserDao.save();
    }
}
